package com.vvlive.caibao.smartcity.utils;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import smartcity.vvlive.caibao.com.smartc.R;


public class NotificationUtil {

	/**
	 * 发送一个状态栏通知
	 * @param context		// 上下文
	 * @param tickerText
	 * @param contentTitle
	 * @param contentText
	 * @param intent
	 * @return
	 */
	@SuppressWarnings("deprecation") public static NotificationManager send(Context context, String tickerText, String contentTitle, String contentText, Intent intent){
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
		NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		Notification notification = new Notification(R.mipmap.ic_launcher, tickerText, 1000);
		notification.flags = Notification.FLAG_AUTO_CANCEL;
//		notification.setLatestEventInfo(context, contentTitle, contentText, pendingIntent);
		manager.notify(0, notification);
		return manager;
	}
}
